package com.scau.database.controller.storemanager;

import com.scau.data.entity.EnterWareDO;
import com.scau.database.entity.storemanager.DoEnterDTO;
import com.scau.database.entity.storemanager.EnterDTO;
import com.scau.database.entity.storemanager.PassVO;
import com.scau.database.entity.storemanager.ServiceVO;
import com.scau.database.service.storemanager.StoreManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

@RestController
@RequestMapping("/api/warehouse")
public class StoreManagerController {
    @Autowired
    StoreManagerService storeManagerService;

    @GetMapping("/enter/{warehouseID}/{page}")
    public EnterDTO getEnters(@PathVariable("warehouseID") String warehouseID, @PathVariable("page") String page) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
//        System.out.println(warehouseID+"号仓库查询第"+page+"页的进仓表");
        Integer iwID = Integer.valueOf(warehouseID);
        Long iPage = Long.valueOf(page);
        return storeManagerService.getEnters(iwID,iPage);
    }
    @PostMapping("/doenter")
    public Integer doEnter(@RequestBody  DoEnterDTO doEnterDTO){
//        System.out.println(doEnterDTO);
        return storeManagerService.doEnter(doEnterDTO);
    }
    @GetMapping("/apply/{warehouseId}")
    public List<PassVO> getApplies(@PathVariable("warehouseId") Integer warehouseId){
//        System.out.println(warehouseId+"号仓库查询申请请求");
        return storeManagerService.getApplies(warehouseId);
    }
    @PostMapping("/pass/{warehouseId}")
    public Integer passApply(@RequestBody PassVO passVO,@PathVariable("warehouseId") Integer warehouseId) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
//        System.out.println("接收到"+warehouseId+"号仓库的通过申请");
//        System.out.println(passVO);
        return storeManagerService.passApply(passVO,warehouseId);
    }
    @GetMapping("/service/{warehouseId}")
    public List<ServiceVO> getServices(@PathVariable("warehouseId") Integer warehouseId){
//        System.out.println("收到"+warehouseId+"号仓库售后信息请求");
        return storeManagerService.getService(warehouseId);
    }
    @PostMapping("/service/{warehouseId}")
    public Integer doService(@PathVariable("warehouseId") Integer warehouseId,@RequestBody ServiceVO serviceVO){
//        System.out.println("收到["+warehouseId+"]号仓库的处理请求：");
//        System.out.println(serviceVO);
        return storeManagerService.doService(warehouseId,serviceVO);
    }
}
